<?php 

require("../include/config.php");
require("../API/php/fonctions.php");
require("../API/php/header.php");

// phpsql/mysql_getUsers.php?milis=123456789&date=2011-11-16&crtl=ok

//[X][0] = responsable
//[X][0] = resp_nom
//[X][0] = resp_prenom

// IN obligatoire
$arrayGet = array(
    "crtl" => null
);

$arrayValeur = recupGet($arrayGet, $bolDecode);

if($arrayValeur["error"] == null){
	// CONNECION SQL
	$db = mysql_connect($host, $base, $mdp)  or die('Erreur de connexion '.mysql_error());

	// CONNECION BASE
	mysql_select_db($base,$db)  or die('Erreur de selection '.mysql_error()); 

	if(isset($_GET["date"])){
		$date = utf8_decode($_GET["date"]);
	
		if (($date!= "")and($date!="undefined")){
			$sql = "SELECT a.`responsable` , a.`resp_nom`, a.`resp_prenom`
			FROM `vue_list_respon` a, `effectifs` b
			WHERE 1=1
			AND a.`responsable` = b.`responsable`
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' 
			AND '".$date."' between b.date_in and b.date_out
			ORDER BY `responsable` ASC 
			;";
		}else{
			$sql = "SELECT a.`responsable` , a.`resp_nom`, a.`resp_prenom`
			FROM `vue_list_respon` a, `effectifs` b
			WHERE 1=1
			AND a.`responsable` = b.`responsable`
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' 
			ORDER BY `responsable` ASC 
			;";
		}
	}else{
		$sql = "SELECT a.`responsable` , a.`resp_nom`, a.`resp_prenom`
		FROM `vue_list_respon` a, `effectifs` b
		WHERE 1=1
		AND a.`responsable` = b.`responsable`
		AND b.date_in != '0000-00-00' 
		AND b.date_out != '0000-00-00' 
		ORDER BY `responsable` ASC 
		;";
	}

	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['responsable'].'&'.$data['resp_nom'].'&'.$data['resp_prenom'].'&'." \r\n"; 
	}

	// DECONNECION SQL
	mysql_close();
}else{
	$strSorti = "ERROR:".$arrayValeur["error"];
}

require("../API/php/footer.php");
?>